package com.bhkj.pdjhbgnewproject.core.activity;

import android.content.Intent;
import android.support.constraint.ConstraintLayout;
import android.text.TextUtils;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;

import com.bhkj.pdjhbgnewproject.R;
import com.bhkj.pdjhbgnewproject.common.contanct.Contacts;
import com.bhkj.pdjhbgnewproject.core.base.BaseActivity;


/**
 * 提示界面
 */
public class TipActivity extends BaseActivity {

    private ConstraintLayout rootView;

    @Override
    public int getLayoutId() {
        screenFull();
        return R.layout.activity_tip;
    }

    @Override
    protected void onNewIntent(Intent intent) {
        super.onNewIntent(intent);
        setBgTip(intent);
    }

    @Override
    public void initView() {
        rootView = findViewById(R.id.root_view);

    }

    @Override
    public void initData() {
        setBgTip(getIntent());
    }

    /**
     * 全屏展示
     */
    private void screenFull() {
        Window window = getWindow();
        //隐藏屏幕底部虚拟按键
        WindowManager.LayoutParams params = window.getAttributes();
        params.systemUiVisibility = View.SYSTEM_UI_FLAG_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_IMMERSIVE;
        window.setAttributes(params);
        requestWindowFeature(Window.FEATURE_NO_TITLE);
        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
                WindowManager.LayoutParams.FLAG_FULLSCREEN);
    }


    private void setBgTip(Intent intent) {
        if (intent != null) {
            String codeTip = intent.getStringExtra(Contacts.PUSH_TIP);
            if (TextUtils.isEmpty(codeTip)) {
                return;
            }

            //暂停服务
            if (codeTip.contains(Contacts.PUSH_STOP_SERVICE)) {
                rootView.setBackgroundResource(R.drawable.bg_stop_service);
                //停止服务
            } else if (codeTip.contains(Contacts.PUSH_END_SERVICE)) {
                rootView.setBackgroundResource(R.drawable.bg_end_service);
                //恢复服务
            } else if (codeTip.contains(Contacts.PUSH_RESUME_SERVICE)) {
                finish();
            }

        }
    }
}
